﻿using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbpEntityFrameworkcore.DbContext;

namespace AbpEntityFrameworkcore.DbContextDesignFac
{
    public class DbContextDesignTimeFactory : IDesignTimeDbContextFactory<MyUserDbContext>
    {
        //string Lmsconnstr = Environment.GetEnvironmentVariable("常州贸联", EnvironmentVariableTarget.Machine);
        string Lmsconnstr = ConfigStaticHelper.GetDbConnect() ;
        public MyUserDbContext CreateDbContext(string[] args)
        {
            DbContextOptionsBuilder<MyUserDbContext> builder =
            new DbContextOptionsBuilder<MyUserDbContext>();
        
            builder.UseSqlServer(Lmsconnstr, sqlOptions =>
            {
                sqlOptions.CommandTimeout(3);
                //我设置了时间为1秒 可是还是会等待连接好一阵子
          
            });
            return new MyUserDbContext(builder.Options);
        }
    }
}
